package com.cycplus.test.base

import android.app.Application
import androidx.lifecycle.AndroidViewModel
import com.cycplus.test.base.ContextProvider
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.disposables.Disposable

open class BaseViewModel(application: Application = ContextProvider.applicationContext as Application) : AndroidViewModel(application) {

	private val disposable by lazy { CompositeDisposable() }

	override fun onCleared() {
		disposable.dispose()
		super.onCleared()
	}

	protected fun Disposable.add() {
		disposable.add(this)
	}
}